﻿using System;
using Heb2RusEngine;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Heb2RusTests
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestClass]
    public class UnitTests
    {
        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext { get; set; }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestHebrewAlphaBet()
        {
            Assert.AreEqual('א', HebrewAlphabet.Alef);
            Assert.AreEqual('ב', HebrewAlphabet.Bet);
            Assert.AreEqual('ג', HebrewAlphabet.Gimel);
            Assert.AreEqual('ד', HebrewAlphabet.Dalet);
            Assert.AreEqual('ה', HebrewAlphabet.He);
            Assert.AreEqual('ו', HebrewAlphabet.Vav);
            Assert.AreEqual('ז', HebrewAlphabet.Zayin);
            Assert.AreEqual('ח', HebrewAlphabet.Het);
            Assert.AreEqual('ט', HebrewAlphabet.Tet);
            Assert.AreEqual('י', HebrewAlphabet.Yod);
            Assert.AreEqual('כ', HebrewAlphabet.Kaf);
            Assert.AreEqual('ך', HebrewAlphabet.FinalKaf);
            Assert.AreEqual('ל', HebrewAlphabet.Lamed);
            Assert.AreEqual('מ', HebrewAlphabet.Mem);
            Assert.AreEqual('ם', HebrewAlphabet.FinalMem);
            Assert.AreEqual('נ', HebrewAlphabet.Nun);
            Assert.AreEqual('ן', HebrewAlphabet.FinalNun);
            Assert.AreEqual('ס', HebrewAlphabet.Samekh);
            Assert.AreEqual('ע', HebrewAlphabet.Ayin);
            Assert.AreEqual('פ', HebrewAlphabet.Pe);
            Assert.AreEqual('ף', HebrewAlphabet.FinalPe);
            Assert.AreEqual('צ', HebrewAlphabet.Tsadi);
            Assert.AreEqual('ץ', HebrewAlphabet.FinalTsadi);
            Assert.AreEqual('ק', HebrewAlphabet.Qof);
            Assert.AreEqual('ר', HebrewAlphabet.Resh);
            Assert.AreEqual('ש', HebrewAlphabet.Shin);
            Assert.AreEqual('ת', HebrewAlphabet.Tav);
        }

        [TestMethod]
        public void TestRule2()
        {
            const string hebrewInput = "בבּגדזחטכךכּךּלמםנןספףפּףּצץקר ש שׁ שׂת";
            const string expectedRussianResult = "вбгдзхтххкклммннсффппццкр ш ш ст";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }

        [TestMethod]
        public void TestRule4_01_Patax()
        {
            string hebrewInput = "לַ";
            string expectedRussianResult = "ла";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);

            hebrewInput = "סַ";
            expectedRussianResult = "са";
            translit = new Hebrew2RussianTranslit();
            actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule4_02_Kamatz()
        {
            string hebrewInput = "לָ";
            string expectedRussianResult = "ла";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);

            hebrewInput = "זָ";
            expectedRussianResult = "за";
            translit = new Hebrew2RussianTranslit();
            actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule4_03_Zeire()
        {
            string hebrewInput = "לֵ";
            string expectedRussianResult = "лэ";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);

            hebrewInput = "נֵ";
            expectedRussianResult = "нэ";
            translit = new Hebrew2RussianTranslit();
            actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule4_04_Segol()
        {
            string hebrewInput = "לֶ";
            string expectedRussianResult = "лэ";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);

            hebrewInput = "רֶ";
            expectedRussianResult = "рэ";
            translit = new Hebrew2RussianTranslit();
            actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule4_05_Hiriq()
        {
            string hebrewInput = "לִ";
            string expectedRussianResult = "ли";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);

            hebrewInput = "עִ";
            expectedRussianResult = "и";
            translit = new Hebrew2RussianTranslit();
            actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule4_06_Kubutz()
        {
            string hebrewInput = "חֻ";
            string expectedRussianResult = "ху";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);

            hebrewInput = "אֻ";
            expectedRussianResult = "у";
            translit = new Hebrew2RussianTranslit();
            actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule4_07_Holam()
        {
            string hebrewInput = "לֹ";
            string expectedRussianResult = "ло";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);

            hebrewInput = "ה" + HebrewNiqqud.Holam;
            expectedRussianResult = "о";
            translit = new Hebrew2RussianTranslit();
            actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule4_08_Exception()
        {
            const string hebrewInput = "חַ";
            const string expectedRussianResult = "ах";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule4_08_noException()
        {
            const string hebrewInput = "תַּחַת";
            const string expectedRussianResult = "тахат";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule4_09_Exception()
        {
            const string hebrewInput = "סְלָחָה";
            const string expectedRussianResult = "селаха";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule4_10_Exception()
        {
            string hebrewInput = "מֲ";
            string expectedRussianResult = "ма";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);

            hebrewInput = "מֱ";
            expectedRussianResult = "мэ";
            translit = new Hebrew2RussianTranslit();
            actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);

            hebrewInput = "מֳ";
            expectedRussianResult = "мо";
            translit = new Hebrew2RussianTranslit();
            actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule4_11_Exception()
        {
            string hebrewInput = "רוּחַ";
            string expectedRussianResult = "руах";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);

            hebrewInput = ".רוּחַ.";
            expectedRussianResult = ".руах.";
            translit = new Hebrew2RussianTranslit();
            actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }

        [TestMethod]
        public void TestRule5_1()
        {
            string hebrewInput = "לוּ";
            string expectedRussianResult = "лу";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);

            hebrewInput = "סוּ";
            expectedRussianResult = "су";
            actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule5_2()
        {
            const string hebrewInput = "תּוֹ";
            const string expectedRussianResult = "то";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        [Ignore]
        public void TestRule5_3()
        {
            const string hebrewInput = "בְּמִצְוֹתָיו";
            const string expectedRussianResult = "бемицвотав";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule5_4()
        {
            const string hebrewInput = "וְצִוָּנוּ";
            const string expectedRussianResult = "вецивану";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule5_5()
        {
            const string hebrewInput = "שׂוֹרֵק";
            const string expectedRussianResult = "сорэк";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule5_6()
        {
            const string hebrewInput = "וַעֲשׂוּ";
            const string expectedRussianResult = "ваасу";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }

        [TestMethod]
        public void TestRule6_1()
        {
            const string hebrewInput = "קְרוֹבַי";
            const string expectedRussianResult = "керовай";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        [Ignore]
        public void TestRule6_2()
        {
            const string hebrewInput = "מָרְדְּכַי";
            const string expectedRussianResult = "мардехай";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule6_3_1()
        {
            const string hebrewInput = "יָקְשָׁה";
            const string expectedRussianResult = "йакеша";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule6_3_2()
        {
            const string hebrewInput = "וְיֵדְעוּ";
            const string expectedRussianResult = "вейэдеу";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule6_3_3()
        {
            const string hebrewInput = "כּוֹרְעִים";
            const string expectedRussianResult = "кореим";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule6_3_4()
        {
            const string hebrewInput = "חוּמְשֵׁי";
            const string expectedRussianResult = "хумешэй";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule6_3_5()
        {
            const string hebrewInput = "בָּרוּךְ";
            const string expectedRussianResult = "барух";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        [Ignore]
        public void TestRule6_3_6()
        {
            const string hebrewInput = "וּקְרוֹבוֹתַי";
            const string expectedRussianResult = "укровотай";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        [Ignore]
        public void TestRule6_3_7()
        {
            const string hebrewInput = "מִישְׁבֵי";
            const string expectedRussianResult = "мишевэй";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        [Ignore]
        public void TestRule6_4()
        {
            const string hebrewInput = "וְקִיְּמָנוּ";
            const string expectedRussianResult = "векийеману";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule6_5()
        {
            const string hebrewInput = "הַלְלוּ";
            const string expectedRussianResult = "алелу";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule6_6()
        {
            const string hebrewInput = "הַמְהֻלָּל";
            const string expectedRussianResult = "амеулаль";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule6_7()
        {
            const string hebrewInput = "שַׁבְּתוֹתַי";
            const string expectedRussianResult = "шабетотай";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }

        [TestMethod]
        public void TestRule9()
        {
            const string hebrewInput = "עֲזַרְיָה";
            const string expectedRussianResult = "азар'йа";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }

        [TestMethod]
        public void TestRule12_1()
        {
            const string hebrewInput = "יְהֹוָה";
            const string expectedRussianResult = "А-доной";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
        [TestMethod]
        public void TestRule12_2()
        {
            string hebrewInput = String.Format("{0}{1} ", HebrewAlphabet.Yod, HebrewAlphabet.Yod);
            const string expectedRussianResult = "А-доной ";
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
    }

    [TestClass]
    public class UnitTests_Rule_7
    {
        const string FORMAT_TEST_LINE = "|    {0}   |   {1}    |   {2}  |   {3}  |";

        [TestInitialize]
        public void Init()
        {
            Console.WriteLine("");
            Console.WriteLine(String.Format(FORMAT_TEST_LINE, "input", "expected", "actual", "status"));
        }
        [TestMethod]
        [Ignore]
        public void TestRule7_1()
        {
            const string hebrewInput = "אֱלִיעֶזֶר";
            const string expectedRussianResult = "элиэзер";
            DoTest(hebrewInput, expectedRussianResult);
        }
        [TestMethod]
        public void TestRule7_2()
        {
            const string hebrewInput = "רַבּוֹתֵינוּ";
            const string expectedRussianResult = "работэну";
            DoTest(hebrewInput, expectedRussianResult);
        }
        [TestMethod]
        public void TestRule7_3()
        {
            const string hebrewInput = "מִצְרַיִם";
            const string expectedRussianResult = "мицрайим";
            DoTest(hebrewInput, expectedRussianResult);
        }
        [TestMethod]        
        [Ignore]
        public void TestRule7_4()
        {
            const string hebrewInput = "עֲזַרְיָה";
            const string expectedRussianResult = "азарйа";
            DoTest(hebrewInput, expectedRussianResult);
        }
        [TestMethod]
        public void TestRule7_5()
        {
            const string hebrewInput = "יְמֵי";
            const string expectedRussianResult = "йемэй";
            DoTest(hebrewInput, expectedRussianResult);
        }
        [TestMethod]
        public void TestRule7_6()
        {
            const string hebrewInput = "צִיצִית";
            const string expectedRussianResult = "цицит";
            DoTest(hebrewInput, expectedRussianResult);
        }
        [TestMethod]
        public void TestRule7_7()
        {
            const string hebrewInput = "כִּי";
            const string expectedRussianResult = "ки";
            DoTest(hebrewInput, expectedRussianResult);
        }
        [TestMethod]
        public void TestRule7_8()
        {
            const string hebrewInput = "מִזִּיו";
            const string expectedRussianResult = "мизив";
            DoTest(hebrewInput, expectedRussianResult);
        }
        [TestMethod]
        public void TestRule7_9()
        {
            const string hebrewInput = "אֶחָיו";
            const string expectedRussianResult = "эхав";
            DoTest(hebrewInput, expectedRussianResult);
        }

        static void DoTest(string hebrewInput, string expectedRussianResult)
        {
            Hebrew2RussianTranslit translit = new Hebrew2RussianTranslit();
            string actualRussianResult = translit.ConvertLine(hebrewInput);
            Console.WriteLine(String.Format(FORMAT_TEST_LINE, hebrewInput, expectedRussianResult, actualRussianResult, expectedRussianResult == actualRussianResult));
            Assert.AreEqual(expectedRussianResult, actualRussianResult);
        }
    }
}
